package chapter8.HomeWork;
/**
 * 定义一个Person类{name,age,job}，初始化Person数组，有三个Person对象，并按照
 * age从大到小进行排序，使用冒泡排序
 * **/
public class HomeWork01 {
    public static void main(String[] args) {
        Person person = new Person("smith",20,"worker");
        Person person1 = new Person("joey",21,"coder");
        Person person2 = new Person("smith",22,"cop");
        Person[] p = {person,person1,person2};
        for (int i = 0;i<p.length-1;i++){
            for (int j = i+1;j<p.length;j++){
                if (p[i].age<p[j].age){
                    Person person3 = new Person(p[i].name,p[i].age,p[i].job);
                    p[i]=p[j];
                    p[j]=person3;
                }
            }

            }
        for (int j = 0; j <p.length; j++) {
            System.out.println("\n"+p[j].name+"\t"+p[j].age+"\t"+p[j].job);
        }
    }

}
class Person{
    String name;
    int age;
    String job;

    public Person(String name, int age, String job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }
}